/**
* @file        SignalDeliverChainBuilder
* @brief       
* @version     1.0.0
* @author      Changlin.Jing 
* @date        2023/2/16 14:22
* @copyright   Copyright  2022 Langge Software Co., Ltd. All rights reserved.
*/
#include "LocSignalDeliverChainBuilder.hpp"
#include "LocSignalDeliverFactory.hpp"
BEGIN_SPACE_LANGE_VDR

vdr::PlaybackLocSignalDeliverChainBuilder::PlaybackLocSignalDeliverChainBuilder() = default;

vdr::PlaybackLocSignalDeliverChainBuilder::~PlaybackLocSignalDeliverChainBuilder() = default;

vdr::RealTimeLocSignalDeliverChainBuilder::~RealTimeLocSignalDeliverChainBuilder() = default;

vdr::RealTimeLocSignalDeliverChainBuilder::RealTimeLocSignalDeliverChainBuilder() {
    // 信号过滤
    mDeliverIdList.push_back(SIGNAL_DELIVER_LOC_SIGNAL_FILTER);
    // 位置质量评估
    mDeliverIdList.push_back(SIGNAL_DELIVER_LOCATION_QUALITY_ESTIMATOR);
    // 姿态估计
    mDeliverIdList.push_back(SIGNAL_DELIVER_ATTITUDE_ESTIMATOR);
    // 位置融合
    mDeliverIdList.push_back(SIGNAL_DELIVER_POSITION_ESTIMATOR);
    // 速度估计
    mDeliverIdList.push_back(SIGNAL_DELIVER_SPEED_ESTIMATOR);
}


void vdr::RealTimeLocSignalDeliverChainBuilder::makeDeliverIdList() {

}

void vdr::PlaybackLocSignalDeliverChainBuilder::makeDeliverIdList() {

}

std::unique_ptr<LocSignalDeliverChainBuilder>
vdr::LocSignalDeliverChainBuilderFactory::createDeliverChainBuilder(const WorkState &workState) {
    std::unique_ptr<LocSignalDeliverChainBuilder> deliverChainBuilder(nullptr);
    deliverChainBuilder = std::make_unique<RealTimeLocSignalDeliverChainBuilder>();
    return deliverChainBuilder;

}

std::shared_ptr<vdr::ILocSignalDeliver>
vdr::LocSignalDeliverChainBuilder::createLocSignalDeliverChain(const WorkState &workState) {
    std::shared_ptr<ILocSignalDeliver> signalDeliver(nullptr);
    std::shared_ptr<ILocSignalDeliver> deliverEnd(nullptr);

    makeDeliverIdList();

    // 反向遍历
    auto riter = mDeliverIdList.rbegin();
    for(;riter!=mDeliverIdList.rend();++riter){
        signalDeliver = LocSignalDeliverFactory::make(workState,deliverEnd,*riter);
        if(nullptr!=signalDeliver){
            deliverEnd = signalDeliver;
        }
    }

    return (nullptr!=signalDeliver)?signalDeliver:deliverEnd;
}

END_SPACE_LANGE_VDR
